package route

import (
	"github.com/doujunyu/gogo/gogo"
	"github.com/doujunyu/gogo/job"
	"go_self/common"
	"go_self/controller"
	"go_self/controller_admin"
)

func Route(r *gogo.Centre) {
	//跨域
	r.Middleware = append(r.Middleware, common.CrossDomain)
	r.Middleware = append(r.Middleware, common.TokenInput)
	//用户--------------------------------------------------------------------------------------------------------------+
	//账号登录
	r.POST("/LoginByUsername", controller.LoginByUsername)
	//账号注册
	r.POST("/RegisterByUsername", controller.RegisterByUsername)
	//首页
	r.GET("/HomePage", controller.HomePage)
	//首页商品
	r.GET("/GoodsList", controller.GoodsList)
	//商品搜索
	r.GET("/GoodsSearch", controller.GoodsSearch)

	//商品详情
	r.GET("/GoodsInfo", controller.GoodsInfo)
	//商品统计价格
	r.GET("/GoodsByPriceAll", controller.GoodsByPriceAll)

	//我的
	r.GET("/UserByHome", controller.CheckToken, controller.UserByHome)
	//申请店铺
	//r.POST("/ShopByApply", controller.CheckToken, controller.ShopByApply)
	//收货地址列表
	r.GET("/UserAddressByList", controller.CheckToken, controller.UserAddressByList)
	//收货地址添加
	r.POST("/UserAddressByAdd", controller.CheckToken, controller.UserAddressByAdd)
	//收货地址编辑
	r.POST("/UserAddressByEdit", controller.CheckToken, controller.UserAddressByEdit)
	//收货地址更改默认值
	r.POST("/UserAddressByEditIsDefault", controller.CheckToken, controller.UserAddressByEditIsDefault)
	//收货地址删除
	r.POST("/UserAddressByDel", controller.CheckToken, controller.UserAddressByDel)

	//加入购物车
	r.POST("/UserShoppingCartByAdd", controller.CheckToken, controller.UserShoppingCartByAdd)
	//购物车列表
	r.GET("/UserShoppingCartByList", controller.CheckToken, controller.UserShoppingCartByList)
	//购物车删除商品
	r.POST("/UserShoppingCrtByDel", controller.CheckToken, controller.UserShoppingCrtByDel)
	//购物车更改商品数量
	r.POST("/UserShoppingCrtByEditNumber", controller.CheckToken, controller.UserShoppingCrtByEditNumber)

	//预展示订单
	r.GET("/OrderByPlaceOrder", controller.CheckToken, controller.OrderByPlaceOrder)
	//生成订单
	r.POST("/OrderByCreateOrder", controller.CheckToken, controller.OrderByCreateOrder)

	//订单列表
	r.GET("/OrderByList", controller.CheckToken, controller.OrderByList)
	//订单确认收货
	r.POST("/OrderByToWaitDiscuss", controller.CheckToken, controller.OrderByToWaitDiscuss)
	//订单评价
	r.POST("/OrderByToFinish", controller.CheckToken, controller.OrderByToFinish)



	//总后台接口---------------------------------------------------------------------------------------------------------+
	//管理员登录
	r.POST("/Admin/LoginByUsername", controller_admin.LoginByUsername)
	//用户列表
	r.GET("/Admin/UserByList", controller_admin.CheckToken, controller_admin.UserByList)


	//商品种类列表
	r.GET("/Admin/CategoryByList", controller_admin.CheckToken, controller_admin.CategoryByList)
	//商品种类添加
	r.POST("/Admin/CategoryByAdd", controller_admin.CheckToken, controller_admin.CategoryByAdd)
	//商品种类编辑
	r.POST("/Admin/CategoryByEdit", controller_admin.CheckToken, controller_admin.CategoryByEdit)
	//商品种类删除
	r.POST("/Admin/CategoryByDel", controller_admin.CheckToken, controller_admin.CategoryByDel)

	//商品录入
	r.POST("/Admin/GoodsByAdd", controller_admin.CheckToken, controller_admin.GoodsByAdd)
	//商品列表
	r.GET("/Admin/GoodsByList", controller_admin.CheckToken, controller_admin.GoodsByList)
	//商品更改上下架
	r.POST("/Admin/GoodsByUpDown", controller_admin.CheckToken, controller_admin.GoodsByUpDown)
	//商品软删除
	r.POST("/Admin/GoodsByDel", controller_admin.CheckToken, controller_admin.GoodsByDel)

	//商品规格key列表
	r.GET("/Admin/AttributeKeyByList", controller_admin.CheckToken, controller_admin.AttributeKeyByList)
	//商品规格key添加
	r.POST("/Admin/AttributeKeyByAdd", controller_admin.CheckToken, controller_admin.AttributeKeyByAdd)
	//商品规格key编辑
	r.POST("/Admin/AttributeKeyByEdit", controller_admin.CheckToken, controller_admin.AttributeKeyByEdit)
	//商品规格key删除
	r.POST("/Admin/AttributeKeyByDel", controller_admin.CheckToken, controller_admin.AttributeKeyByDel)

	//商品属性value列表
	r.GET("/Admin/AttributeValueByList", controller_admin.CheckToken, controller_admin.AttributeValueByList)
	//商品属性value添加
	r.POST("/Admin/AttributeValueByAdd", controller_admin.CheckToken, controller_admin.AttributeValueByAdd)
	//商品属性value编辑
	r.POST("/Admin/AttributeValueByEdit", controller_admin.CheckToken, controller_admin.AttributeValueByEdit)
	//商品属性value删除
	r.POST("/Admin/AttributeValueByDel", controller_admin.CheckToken, controller_admin.AttributeValueByDel)

	//订单列表
	r.GET("/Admin/OrderByList", controller_admin.CheckToken, controller_admin.OrderByList)
	//订单发货
	r.POST("/Admin/OrderBySendGoods", controller_admin.CheckToken, controller_admin.OrderBySendGoods)

	//公共接口-----------------------------------------------------------------------------------------------------------+
	//主订单支付回调
	r.POST("/OrderPayBack", common.OrderPayBack)
	//子订单支付回调
	r.POST("/OrderByPayChildBack", common.OrderByPayChildBack)


	//图片上传
	r.POST("/PictureUpLoading", common.ByPictureUpLoading)
	//文件下载
	r.GET("/download/", common.ByDownLoad)
	//访问public下面的文件
	r.GET("/static/", common.ByPublic)
	//服务器关闭接口
	r.POST("/configByOver", func(j *job.Job) {
		if j.Input["password"] == "init0" {
			r.ServerClose <- 1
			j.JsonSuccess(nil, "操作成功")
			return
		}
		j.JsonError(nil, "密码错误")
	})
	//默认接口
	r.GET("/", func(j *job.Job) {
		j.JsonError(nil, "接口不存在")
	})
	r.POST("/", func(j *job.Job) {
		j.JsonError(nil, "接口不存在")
	})
}
